#!/usr/bin/python
# -*- coding: UTF-8 -*-

# 引用automagica的核心库，鼠标、键盘、浏览器、系统应用、Office、PDF等操作函数，都依赖于该模块。
from automagica import *
import requests
from lxml import etree

# 运行迅雷
run(r'D:\Thunder\Program\ThunderStart.exe')

# 移动鼠标
move_mouse_to(x=456, y=301)
# 点击新建任务
click(x=456, y=301)

# 移动到输入框位置
move_mouse_to(x=808, y=466)

# 电影网站
url = 'https://www.9tata.com/content/14371.html'
with requests.get(url) as res:
    content = res.content
    html = etree.HTML(content)

# 获取ed2k链接
ed2k_url = html.xpath('/html/body/section/div/div/div/article/div[5]/table/tbody/tr/td/a[1]/@href')

# 循环输入
for i in ed2k_url:
    # 输入url
    press_key(i)
    # 输入回车键，用来换行
    press_key('enter')

# 点击立即下载
click(x=963, y=773)